package com.liuhung.ash.security.service;

import java.util.List;

import org.apache.log4j.Logger;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.liuhung.base.service.BaseService;
import com.liuhung.ash.security.dao.OrganDao;
import com.liuhung.ash.security.entity.Organ;

/**
 * 
 * <br>
 * <b>功能：</b>OrganService<br>
 */
@Service("organService")
@Transactional
public class OrganService extends BaseService<Organ> {
	private final static Logger log= Logger.getLogger(OrganService.class);
	

	

	@Autowired
    private OrganDao<Organ> dao;

		
	public OrganDao<Organ> getDao() {
		return dao;
	}
	
	public void cascadeDelete(Organ organ){
		List<Organ> tList=dao.queryChild( organ.getId());
		if(tList.size()>0)
		{
			for(Organ o:tList)
			{
				cascadeDelete(o);
			}
		}
		else {
			try {
				delete( organ.getId());
			} catch (Exception e) {
				e.printStackTrace();
				log.error("删除出现异常！");
			}
		}
		
	}
	
	
	

}
